#!/usr/bin/python
# -*- coding: UTF-8 -*-

""" 
@version: 1.0
@author: jin.li.o
@license: Apache Licence 
@contact: x.leevin@gmail.com
@software: PyCharm
@file: clazz_i_01.py
@time: 2018/9/30
"""

str_input = input("请输入一个四位数数字:")

if str_input.isdigit():
    int_num = int(str_input)

    numList = [(int_num // 1000) % 10, (int_num // 100) % 10, (int_num // 10) % 10, int_num % 10]
    print("用户输入:{0}".format(numList))

    # 1.每一位+5
    for i in range(0, len(numList)):
        numList[i] = numList[i] + 5

    print("+5后的结果:{0}".format(numList))

    # 2.除10取余
    for i in range(0, len(numList)):
        numList[i] = numList[i] % 10

    print("取模后的结果:{0}".format(numList))

    # 3.换位置
    num1 = numList[0]
    num2 = numList[1]
    num3 = numList[2]
    num4 = numList[3]

    numList[0] = num4
    numList[3] = num1

    numList[1] = num3
    numList[2] = num2

    print("换位置后的结果:{0}".format(numList))

    # 4.拼接
    result = ""
    # 将int.List转成str.List
    for i in range(0, len(numList)):
        numList[i] = str(numList[i])

    print("拼接后的结果:{0}".format(numList))

    # 5.将集合装成字符串
    result = result.join(numList)
    print("转成字符串后的结果:{0}".format(result))

    # 6.输出最终结果
    print("最终结果:{0}".format(int(result)))


else:
    print("请输入4位数字")
